package com.lxmes.hr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.hr.domain.NcWageArchive;
import com.lxmes.hr.service.INcWageArchiveService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 工资归档Controller
 * 
 * @author ruoyi
 * @date 2022-11-25
 */
@RestController
@RequestMapping("/hr/archive")
public class NcWageArchiveController extends BaseController
{
    @Autowired
    private INcWageArchiveService ncWageArchiveService;

    /**
     * 查询工资归档列表
     */
    @PreAuthorize("@ss.hasPermi('hr:archive:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcWageArchive ncWageArchive)
    {
        startPage();
        List<NcWageArchive> list = ncWageArchiveService.selectNcWageArchiveList(ncWageArchive);
        return getDataTable(list);
    }

    /**
     * 导出工资归档列表
     */
    @PreAuthorize("@ss.hasPermi('hr:archive:export')")
    @Log(title = "工资归档", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcWageArchive ncWageArchive)
    {
        List<NcWageArchive> list = ncWageArchiveService.selectNcWageArchiveList(ncWageArchive);
        ExcelUtil<NcWageArchive> util = new ExcelUtil<NcWageArchive>(NcWageArchive.class);
        util.exportExcel(response, list, "工资归档数据");
    }

    /**
     * 获取工资归档详细信息
     */
    @PreAuthorize("@ss.hasPermi('hr:archive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ncWageArchiveService.selectNcWageArchiveById(id));
    }

    /**
     * 新增工资归档
     */
    @PreAuthorize("@ss.hasPermi('hr:archive:add')")
    @Log(title = "工资归档", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcWageArchive ncWageArchive)
    {
        return toAjax(ncWageArchiveService.insertNcWageArchive(ncWageArchive));
    }

    /**
     * 修改工资归档
     */
    @PreAuthorize("@ss.hasPermi('hr:archive:edit')")
    @Log(title = "工资归档", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcWageArchive ncWageArchive)
    {
        return toAjax(ncWageArchiveService.updateNcWageArchive(ncWageArchive));
    }

    /**
     * 删除工资归档
     */
    @PreAuthorize("@ss.hasPermi('hr:archive:remove')")
    @Log(title = "工资归档", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ncWageArchiveService.deleteNcWageArchiveByIds(ids));
    }
}
